<?php
/**
 * User:于小涛
 * Date:2020/2/17
 * Time:15:37
 */
namespace app\admin\controller\system;

use app\admin\BaseController;
use app\admin\business\file\File;
use app\admin\model\system\Config as ConfigModel;
use think\App;
use think\facade\View;

class Config extends BaseController {
    private $obj_config_model = null;
    private $obj_file_business = null;
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->obj_config_model = new ConfigModel();
        $this->obj_file_business = new File();
    }

    public function setPage(){
        $arr_list=$this->obj_config_model->select()->toArray();
        $arr_list=array_item_key_to_self_key($arr_list,'key');
        $arr_file_info = $this->obj_file_business->getFileFullUrlById($arr_list['background_img']['content']);
        $arr_list['background_img']['content_url'] = $arr_file_info['full_url'];
        View::assign("arr_data",$arr_list);
        return view();
    }

    public function setConfig(){
        $this->obj_config_model->editByKey($this->request->param('key'),$this->request->param('content'));
        return output_data([]);
    }

}